﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ThaiHoa.Win.QLSX.SanXuat.UTI
{
    public static class Developer
    {
        public static void ShowEntityError(System.Data.Entity.Validation.DbEntityValidationException ex)
        {
            var sb = new System.Text.StringBuilder();
            foreach (var failure in ex.EntityValidationErrors)
            {
                sb.AppendFormat("{0} failed validation", failure.Entry.Entity.GetType());
                foreach (var error in failure.ValidationErrors)
                {
                    sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage);
                    sb.AppendLine();
                }
            }

            throw new Exception(sb.ToString());
        }
    }
}
